// 导航面板统一样式文件
// 用于统一所有折叠面板的样式定义，提高样式可维护性

// ==================== 样式变量 ====================
// 面板相关变量
$panel-border-radius: 0;
$panel-header-height: 32px; // 从40px减少到32px，更像IDEA风格
$panel-header-padding: 8px 12px; // 从12px 16px减少到8px 12px，更紧凑
$panel-content-padding: 3px 6px; // 从4px 8px减少到3px 6px，更紧凑

// 列表项相关变量
$list-item-height: 32px; // 从40px减少到32px，更紧凑
$list-item-padding: 6px 10px; // 从8px 12px减少到6px 10px，更紧凑
$list-item-border-radius: 4px;
$list-item-margin-bottom: 2px;
$list-item-selected-border-width: 3px;
$list-item-selected-border-color: var(--n-primary-color, #18a058);
$list-item-selected-bg-color: rgba(64, 158, 255, 0.15);
$list-item-hover-bg-color: var(--n-hover-color, rgba(24, 160, 88, 0.1));

// 按钮相关变量
$button-size-small: 12px; // 从14px减少到12px，更紧凑
$button-size-tiny: 10px; // 从12px减少到10px，更紧凑
$button-gap: 2px; // 从3px减少到2px，更紧凑
$button-hover-scale: 1.02; // 从1.05减少到1.02，更微妙
$button-transition: all 0.15s var(--n-bezier-ease-out); // 保持0.15s不变，更快速

// 动画相关变量
$animation-duration-fast: 0.15s; // 从0.15s保持不变，更快速
$animation-duration-normal: 0.15s; // 从0.2s减少到0.15s，更快速
$animation-duration-slow: 0.2s; // 新增，用于较慢的动画
$animation-bezier: var(--n-bezier-ease-out);

// ==================== 混合器 ====================
// 面板头部样式混合器
@mixin panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0px 8px; // 从8px 12px减少到6px 8px，更紧凑
  background-color: var(--n-card-color);
  border-bottom: 1px solid var(--n-border-color);
  cursor: pointer;
  transition: all 0.15s var(--n-bezier-ease-out); 
  font-size: 13px; 
  min-height: 28px; 
  box-shadow: none; 

  
  &:hover {
    background-color: var(--n-hover-color);
    
    &::after {
      background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.2) 80%,
        transparent 100%
      );
      opacity: 0.5;
    }
  }
}

// 面板头部悬停效果混合器
@mixin panel-header-hover {
  background-color: var(--n-color-6);
  color: var(--n-text-color-1);
  transform: translateX(1px); // 从2px减少到1px，更微妙
}

// 面板头部激活状态混合器
@mixin panel-header-active {
  background-color: var(--n-color-6);
  color: var(--n-text-color-1);
  border-bottom: 2px solid var(--n-primary-color-pressed, #36ad6a);
  transform: translateZ(0);
  box-shadow: none; /* 移除阴影，保持扁平化设计 */
  
  &::after {
    background: linear-gradient(
      to right,
      transparent 0%,
      rgba(54, 173, 106, 0.2) 20%,
      rgba(54, 173, 106, 0.2) 80%,
      transparent 100%
    );
    opacity: 0.6;
  }
}

// 列表项基础样式混合器
@mixin list-item-base {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px; 
  cursor: pointer;
  transition: all 0.15s var(--n-bezier-ease-out); // 从0.2s减少到0.15s，更快速
  border-bottom: 1px solid var(--n-divider-color);
  min-height: 32px; // 从40px减少到32px，更紧凑
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  animation: listItemEnter 0.15s var(--n-bezier-ease-out) forwards; // 从0.2s减少到0.15s，更快速
  box-shadow: none; /* 移除阴影，保持扁平化设计 */
  
  &:last-child {
    border-bottom: none;
  }
  
  &:hover {
    background-color: var(--n-hover-color);
    transform: translateX(1px); // 从2px减少到1px，更微妙
  }
}

// 列表项悬停效果混合器
@mixin list-item-hover {
  background-color: $list-item-hover-bg-color;
  transform: translateX(1px); // 从2px减少到1px，更微妙
}

// 列表项选中状态混合器
@mixin list-item-selected {
  background-color: $list-item-selected-bg-color !important;
  border-left: $list-item-selected-border-width solid $list-item-selected-border-color !important;
  padding-left: calc(6px - #{$list-item-selected-border-width}) !important; // 使用6px而不是$list-item-padding
  animation: listItemSelect 0.15s var(--n-bezier-ease-out) forwards; // 从$animation-duration-normal $animation-bezier改为具体值，与NavigationSidebar.scss保持一致
}

// 操作按钮基础样式混合器
@mixin action-button-base {
  opacity: 0.7;
  transition: all 0.15s var(--n-bezier-ease-out); // 从$button-transition改为具体值，与NavigationSidebar.scss保持一致
  transform: scale(1);
  
  &:hover {
    opacity: 1;
    transform: scale(1.02); // 从$button-hover-scale改为具体值，与NavigationSidebar.scss保持一致
  }
}

// 删除按钮样式混合器
@mixin delete-button {
  opacity: 0.7;
  transition: all 0.15s var(--n-bezier-ease-out); // 从$button-transition改为具体值，与NavigationSidebar.scss保持一致
  transform: scale(1);
  
  &:hover {
    opacity: 1;
    color: var(--n-error-color);
    transform: scale(1.02); // 从$button-hover-scale改为具体值，与NavigationSidebar.scss保持一致
  }
}

// ==================== 关键帧动画 ====================
@keyframes listItemEnter {
  0% {
    opacity: 0;
    transform: translateY(-5px); // 从-10px减少到-5px，更微妙
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes listItemSelect {
  0% {
    background-color: transparent;
    border-left-color: transparent;
  }
  50% {
    background-color: rgba(64, 158, 255, 0.2);
  }
  100% {
    background-color: $list-item-selected-bg-color;
    border-left-color: $list-item-selected-border-color;
  }
}

@keyframes panelExpand {
  0% {
    opacity: 0.9; // 从0.8增加到0.9，更微妙
    transform: scaleY(0.98); // 从0.95增加到0.98，更微妙
    transform-origin: top;
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: top;
  }
}

@keyframes panelCollapse {
  0% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: top;
  }
  100% {
    opacity: 0.9; // 从0.8增加到0.9，更微妙
    transform: scaleY(0.98); // 从0.95增加到0.98，更微妙
    transform-origin: top;
  }
}

// ==================== 统一样式类 ====================
// 导航面板容器类
.navigation-panels-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

// 面板内容区域样式
.panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
  background-color: var(--n-card-color);
  border-top: 1px solid var(--n-divider-color);
  border-bottom: 1px solid var(--n-border-color);
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none; /* 移除阴影，保持扁平化设计 */
}

// 内容包装器类
.content-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0px 8px; // 从$panel-content-padding改为具体值，与NavigationSidebar.scss保持一致
  overflow: hidden;
  box-shadow: none; /* 移除阴影，保持扁平化设计 */
}

// 列表容器类
.list-container {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 4px;
}

// 列表项内容区类
.list-item-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

// 列表项信息区类
.list-item-info {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  margin-right: 8px;
}

// 列表项标题类
.list-item-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-size: 12px; // 从13px减少到12px，更紧凑
}

// 列表项元信息类
.list-item-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px; // 从12px减少到11px，更紧凑
  color: var(--n-text-color-3);
  flex-shrink: 0;
  transition: all $animation-duration-normal $animation-bezier;
  text-align: right;
  margin-left: auto;
}

// 列表项操作区类
.list-item-actions {
  display: flex;
  gap: $button-gap;
  opacity: 0;
  transition: all $animation-duration-normal $animation-bezier;
  flex-shrink: 0;
  margin-left: 8px;
  position: absolute;
  right: 12px;
  transform: translateX(10px);
}

// 面板添加按钮类
.panel-add-button {
  opacity: 0;
  transform: scale(1);
  transition: opacity $animation-duration-normal $animation-bezier, 
              transform $animation-duration-normal $animation-bezier;
  box-shadow: none; /* 移除阴影，保持扁平化设计 */
  
  &:hover {
    opacity: 1;
    transform: scale(1.02); // 从1.05减少到1.02，更微妙
  }
}

// ==================== 状态样式 ====================

// Naive UI 列表项悬停状态
.n-list-item:hover {
  @include list-item-hover;
  
  .list-item-meta {
    opacity: 0 !important;
    visibility: hidden !important;
  }
  
  .list-item-actions {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) !important;
  }
}

// Naive UI 列表项选中状态
.n-list-item.n-list-item--selected {
  @include list-item-selected;
  
  .list-item-meta {
    opacity: 0 !important;
    visibility: hidden !important;
  }
  
  .list-item-actions {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) !important;
  }
}

// 面板头部悬停状态
.panel-header:hover {
  @include panel-header-hover;
}

// 面板头部激活状态
.panel-header.panel-header-active {
  @include panel-header-active;
}

// 面板悬停时显示添加按钮
.n-collapse-item:not(.n-collapse-item--disabled):hover .panel-add-button {
  opacity: 1;
}

// 确保选中状态样式优先级更高
// 使用更具体的选择器确保选中样式能够覆盖默认样式
.navigation-sidebar-component .sidebar-content .n-list-item.n-list-item--selected {
  background-color: $list-item-selected-bg-color !important;
  border-left: $list-item-selected-border-width solid $list-item-selected-border-color !important;
  padding-left: calc(#{$list-item-padding} - #{$list-item-selected-border-width}) !important;
}

// 增强选中状态的样式优先级
// 确保在所有情况下都能正确显示选中状态
.navigation-sidebar-component .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected,
.navigation-sidebar-component .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected:hover,
.navigation-sidebar-component .sidebar-content .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected,
.navigation-sidebar-component .sidebar-content .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected:hover {
  background-color: $list-item-selected-bg-color !important;
  border-left: $list-item-selected-border-width solid $list-item-selected-border-color !important;
  padding-left: calc(#{$list-item-padding} - #{$list-item-selected-border-width}) !important;
  transform: none !important;
}

// 确保选中项的元信息隐藏和操作按钮显示
.navigation-sidebar-component .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .list-item-meta,
.navigation-sidebar-component .sidebar-content .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .list-item-meta {
  opacity: 0 !important;
  visibility: hidden !important;
}

.navigation-sidebar-component .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .list-item-actions,
.navigation-sidebar-component .sidebar-content .n-collapse .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .list-item-actions {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(0) !important;
}

// 为CollapsiblePanel组件添加更高优先级的选中样式
.navigation-sidebar-component .sidebar-content :deep(.n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected) {
  background-color: $list-item-selected-bg-color !important;
  border-left: $list-item-selected-border-width solid $list-item-selected-border-color !important;
  padding-left: calc(#{$list-item-padding} - #{$list-item-selected-border-width}) !important;
}

.navigation-sidebar-component .sidebar-content :deep(.n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .item-meta) {
  opacity: 0 !important;
  visibility: hidden !important;
}

.navigation-sidebar-component .sidebar-content :deep(.n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .item-actions) {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(0) !important;
}

// 为CollapsiblePanel组件添加最高优先级的选中样式
// 使用全局选择器确保样式能够正确应用
:global(.navigation-sidebar-component .sidebar-content .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected) {
  background-color: $list-item-selected-bg-color !important;
  border-left: $list-item-selected-border-width solid $list-item-selected-border-color !important;
  padding-left: calc(#{$list-item-padding} - #{$list-item-selected-border-width}) !important;
}

:global(.navigation-sidebar-component .sidebar-content .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .item-meta) {
  opacity: 0 !important;
  visibility: hidden !important;
}

:global(.navigation-sidebar-component .sidebar-content .n-collapse-item .collapse-content .content-wrapper .n-list-item.n-list-item--selected .item-actions) {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(0) !important;
}

// ==================== 响应式设计 ====================
@media (max-width: 768px) {
  // 在小屏幕上调整列表项高度和内边距
  .list-item {
    min-height: 30px; // 从32px减少到30px，更紧凑
    padding: 5px 8px; // 从6px 10px减少到5px 8px，更紧凑
  }
  
  // 调整面板头部高度和内边距
  .panel-header {
    min-height: 26px; // 从28px减少到26px，更紧凑
    padding: 5px 8px; // 从6px 10px减少到5px 8px，更紧凑
  }
  
  // 调整内容包装器内边距
  .content-wrapper {
    padding: 2px 4px; // 从3px 6px减少到2px 4px，更紧凑
  }
}